let api = [];
api.push({
    alias: 'AppUserAgreementController',
    order: '1',
    link: 'app用户基础信息_--_用户_--_隐私',
    desc: 'App用户基础信息 -- 用户 -- 隐私',
    list: []
})
api[0].list.push({
    order: '1',
    desc: '不带Token获取用户条款或隐私条款',
});
api[0].list.push({
    order: '2',
    desc: '带Token获取用户条款或隐私条款',
});
api.push({
    alias: 'ExchangeController',
    order: '2',
    link: '修改密码/绑定信息/注销账号',
    desc: '修改密码/绑定信息/注销账号',
    list: []
})
api[1].list.push({
    order: '1',
    desc: '修改密码',
});
api[1].list.push({
    order: '2',
    desc: '手机号绑定',
});
api[1].list.push({
    order: '3',
    desc: '更换绑定手机号',
});
api[1].list.push({
    order: '4',
    desc: '验证更换绑定邮箱验证码',
});
api[1].list.push({
    order: '5',
    desc: '更换绑定邮箱',
});
api[1].list.push({
    order: '6',
    desc: '设置账号密码',
});
api[1].list.push({
    order: '7',
    desc: '忘记密码修改 - 短信',
});
api[1].list.push({
    order: '8',
    desc: '忘记密码修改 - 邮箱',
});
api[1].list.push({
    order: '9',
    desc: '永久注销账号-不可逆',
});
api[1].list.push({
    order: '10',
    desc: '永久注销账号-不可逆',
});
api.push({
    alias: 'FirmwareUpgradeController',
    order: '3',
    link: '固件升级',
    desc: '固件升级',
    list: []
})
api[2].list.push({
    order: '1',
    desc: '版本检测',
});
api[2].list.push({
    order: '2',
    desc: '获取升级信息',
});
api[2].list.push({
    order: '3',
    desc: '设备升级',
});
api.push({
    alias: 'LoginController',
    order: '4',
    link: '登录验证',
    desc: '登录验证',
    list: []
})
api[3].list.push({
    order: '1',
    desc: '登录方法',
});
api[3].list.push({
    order: '2',
    desc: '邮箱登录',
});
api[3].list.push({
    order: '3',
    desc: '微信登录',
});
api[3].list.push({
    order: '4',
    desc: 'QQ登录',
});
api[3].list.push({
    order: '5',
    desc: 'Apple ID登录',
});
api[3].list.push({
    order: '6',
    desc: '退出登录',
});
api.push({
    alias: 'AlarmMessageController',
    order: '5',
    link: '系统消息_--_告警消息',
    desc: '系统消息 -- 告警消息',
    list: []
})
api[4].list.push({
    order: '1',
    desc: '获取当前用户所有车辆告警信息',
});
api[4].list.push({
    order: '2',
    desc: '获取告警信息详情',
});
api.push({
    alias: 'SystemMessageController',
    order: '6',
    link: '系统消息_--_系统消息',
    desc: '系统消息 -- 系统消息',
    list: []
})
api[5].list.push({
    order: '1',
    desc: '用户获取系统消息列表',
});
api[5].list.push({
    order: '2',
    desc: '系统消息详情',
});
api.push({
    alias: 'AppActivityUserController',
    order: '7',
    link: 'app弹窗_--',
    desc: 'App弹窗 --',
    list: []
})
api[6].list.push({
    order: '1',
    desc: '获取App弹窗信息',
});
api.push({
    alias: 'AppUserFaqController',
    order: '8',
    link: 'app__faq详情_--',
    desc: 'App  FAQ详情 --',
    list: []
})
api[7].list.push({
    order: '1',
    desc: '查询FAO Info列表',
});
api.push({
    alias: 'SpecificationController',
    order: '9',
    link: '说明书',
    desc: '说明书',
    list: []
})
api[8].list.push({
    order: '1',
    desc: '',
});
api.push({
    alias: 'RegisterController',
    order: '10',
    link: '登录验证',
    desc: '登录验证',
    list: []
})
api[9].list.push({
    order: '1',
    desc: '账号注册',
});
api[9].list.push({
    order: '2',
    desc: '邮箱注册',
});
api.push({
    alias: 'InspectController',
    order: '11',
    link: '服务模块--自检手册',
    desc: '服务模块--自检手册',
    list: []
})
api[10].list.push({
    order: '1',
    desc: '常见故障码信息',
});
api[10].list.push({
    order: '2',
    desc: '根据故障ID查询指定故障信息',
});
api[10].list.push({
    order: '3',
    desc: '根据车辆编码查询',
});
api.push({
    alias: 'SmsCodeController',
    order: '12',
    link: '获取验证码',
    desc: '获取验证码',
    list: []
})
api[11].list.push({
    order: '1',
    desc: '账号注册获取验证码 - 邮箱 | 短信',
});
api[11].list.push({
    order: '2',
    desc: '忘记密码验证码',
});
api[11].list.push({
    order: '3',
    desc: '忘记密码验证码',
});
api[11].list.push({
    order: '4',
    desc: '绑定手机号验证码',
});
api[11].list.push({
    order: '5',
    desc: '更换手机号验证码',
});
api[11].list.push({
    order: '6',
    desc: '用户绑定新手机号验证码',
});
api[11].list.push({
    order: '7',
    desc: '账号注销验证码',
});
api[11].list.push({
    order: '8',
    desc: '邮箱注销验证码',
});
api[11].list.push({
    order: '9',
    desc: '更换绑定邮箱验证码 - 获取当前账号邮箱验证码',
});
api[11].list.push({
    order: '10',
    desc: '更换绑定邮箱验证码 - 获取新邮箱验证码',
});
api.push({
    alias: 'AppUserController',
    order: '13',
    link: 'app用户',
    desc: 'App用户',
    list: []
})
api[12].list.push({
    order: '1',
    desc: '获取App用户详细信息',
});
api[12].list.push({
    order: '2',
    desc: '修改App用户',
});
api[12].list.push({
    order: '3',
    desc: '获取用户当前里程单位',
});
api[12].list.push({
    order: '4',
    desc: '修改当前用户里程单位',
});
api[12].list.push({
    order: '5',
    desc: '根据注册码查询用户',
});
api[12].list.push({
    order: '6',
    desc: '用户图片上传，返回链接地址',
});
api[12].list.push({
    order: '7',
    desc: '设置用户消息推送 deviceToken key',
});
api[12].list.push({
    order: '8',
    desc: '测试推送',
});
api.push({
    alias: 'AppUserEmergencyController',
    order: '14',
    link: 'app用户紧急联系人',
    desc: 'App用户紧急联系人',
    list: []
})
api[13].list.push({
    order: '1',
    desc: '获取当前用户紧急联系人信息',
});
api[13].list.push({
    order: '2',
    desc: '新增/修改紧急联系人信息',
});
api[13].list.push({
    order: '3',
    desc: '用户删除紧急联系人',
});
api.push({
    alias: 'AppUserProblemController',
    order: '15',
    link: 'app用户_--_问题上报反馈',
    desc: 'App用户 -- 问题上报反馈',
    list: []
})
api[14].list.push({
    order: '1',
    desc: '用户问题图片上传，返回链接地址,支持多张上传,结果是图片以，隔开',
});
api[14].list.push({
    order: '2',
    desc: '获取问题类型列表',
});
api[14].list.push({
    order: '3',
    desc: '用户提交问题反馈信息列表',
});
api[14].list.push({
    order: '4',
    desc: '获取当前用户历史反馈问题信息记录',
});
api.push({
    alias: 'UserVehicleController',
    order: '16',
    link: '用户车辆模块',
    desc: '用户车辆模块',
    list: []
})
api[15].list.push({
    order: '1',
    desc: 'App通过扫描二维码获取车架号和秘钥，在获取车辆详情信息',
});
api[15].list.push({
    order: '2',
    desc: '车辆激活',
});
api[15].list.push({
    order: '3',
    desc: '用户车库',
});
api[15].list.push({
    order: '4',
    desc: '车辆详细',
});
api[15].list.push({
    order: '5',
    desc: '设置当前车辆为默认车辆',
});
api[15].list.push({
    order: '6',
    desc: '车辆解绑',
});
api[15].list.push({
    order: '7',
    desc: '首页用户获取车辆车库信息',
});
api[15].list.push({
    order: '8',
    desc: '用户车辆首页信息 --- 默认展示当前用户绑定的车辆信息',
});
api[15].list.push({
    order: '9',
    desc: '用户失窃车辆上报',
});
api.push({
    alias: 'UserVehicleRidingController',
    order: '17',
    link: '用户车辆骑行',
    desc: '用户车辆骑行',
    list: []
})
api[16].list.push({
    order: '1',
    desc: '骑行分析',
});
api[16].list.push({
    order: '2',
    desc: '骑行详情明细 GPS点',
});
api.push({
    alias: 'VehicleDiagnosisController',
    order: '18',
    link: '车辆诊断',
    desc: '车辆诊断',
    list: []
})
api[17].list.push({
    order: '1',
    desc: '故障诊断',
});
api.push({
    alias: 'VehicleFenceController',
    order: '19',
    link: '车辆电子围栏',
    desc: '车辆电子围栏',
    list: []
})
api[18].list.push({
    order: '1',
    desc: '获取当前用户创建的电子围栏信息列表',
});
api[18].list.push({
    order: '2',
    desc: '用户添加电子围栏',
});
api[18].list.push({
    order: '3',
    desc: '用户修改电子围栏',
});
api[18].list.push({
    order: '4',
    desc: '用户删除电子围栏',
});
api.push({
    alias: 'VehicleRealtimeController',
    order: '20',
    link: '车辆实时信息',
    desc: '车辆实时信息',
    list: []
})
api[19].list.push({
    order: '1',
    desc: '车辆实时状态',
});
api.push({
    alias: 'VehicleRemoteController',
    order: '21',
    link: '用户首页车辆控制模块闪灯鸣笛、车辆体检、',
    desc: '用户首页车辆控制模块闪灯鸣笛、车辆体检、',
    list: []
})
api.push({
    alias: 'VehicleSettingsController',
    order: '22',
    link: '车辆设置',
    desc: '车辆设置',
    list: []
})
api[21].list.push({
    order: '1',
    desc: '当前车辆设置信息',
});
api[21].list.push({
    order: '2',
    desc: '恢复默认值',
});
api[21].list.push({
    order: '3',
    desc: '开关设置',
});
api[21].list.push({
    order: '4',
    desc: '开机默认驾驶模式',
});
api[21].list.push({
    order: '5',
    desc: 'SPORT档动力曲线',
});
api[21].list.push({
    order: '6',
    desc: '舒适档动力曲线',
});
api[21].list.push({
    order: '7',
    desc: '防盗器音源选择',
});
api[21].list.push({
    order: '8',
    desc: '按键声音大小',
});
api[21].list.push({
    order: '9',
    desc: '转向声音大小',
});
api[21].list.push({
    order: '10',
    desc: 'TCS 强度',
});
api[21].list.push({
    order: '11',
    desc: '蓝牙强度',
});
api[21].list.push({
    order: '12',
    desc: '车辆报失状态',
});
api[21].list.push({
    order: '13',
    desc: '公英制切换',
});
api[21].list.push({
    order: '14',
    desc: '根据车辆编码查询',
});
api.push({
    alias: 'AppVersionInfoController',
    order: '23',
    link: 'app版本信息',
    desc: 'App版本信息',
    list: []
})
api[22].list.push({
    order: '1',
    desc: '根据手机类型获取App历史版本信息展示',
});
api[22].list.push({
    order: '2',
    desc: '获取单独版本详情',
});
api[22].list.push({
    order: '3',
    desc: '检测App当前版本是否是最新版本',
});
api.push({
    alias: 'dict',
    order: '24',
    link: 'dict_list',
    desc: '数据字典',
    list: []
})
api[23].list.push({
    order: '1',
    desc: 'http状态码字典',
});
document.onkeydown = keyDownSearch;
function keyDownSearch(e) {
    const theEvent = e;
    const code = theEvent.keyCode || theEvent.which || theEvent.charCode;
    if (code == 13) {
        const search = document.getElementById('search');
        const searchValue = search.value;
        let searchArr = [];
        for (let i = 0; i < api.length; i++) {
            let apiData = api[i];
            const desc = apiData.desc;
            if (desc.indexOf(searchValue) > -1) {
                searchArr.push({
                    order: apiData.order,
                    desc: apiData.desc,
                    link: apiData.link,
                    list: apiData.list
                });
            } else {
                let methodList = apiData.list || [];
                let methodListTemp = [];
                for (let j = 0; j < methodList.length; j++) {
                    const methodData = methodList[j];
                    const methodDesc = methodData.desc;
                    if (methodDesc.indexOf(searchValue) > -1) {
                        methodListTemp.push(methodData);
                        break;
                    }
                }
                if (methodListTemp.length > 0) {
                    const data = {
                        order: apiData.order,
                        desc: apiData.desc,
                        link: apiData.link,
                        list: methodListTemp
                    };
                    searchArr.push(data);
                }
            }
        }
        let html;
        if (searchValue == '') {
            const liClass = "";
            const display = "display: none";
            html = buildAccordion(api,liClass,display);
            document.getElementById('accordion').innerHTML = html;
        } else {
            const liClass = "open";
            const display = "display: block";
            html = buildAccordion(searchArr,liClass,display);
            document.getElementById('accordion').innerHTML = html;
        }
        const Accordion = function (el, multiple) {
            this.el = el || {};
            this.multiple = multiple || false;
            const links = this.el.find('.dd');
            links.on('click', {el: this.el, multiple: this.multiple}, this.dropdown);
        };
        Accordion.prototype.dropdown = function (e) {
            const $el = e.data.el;
            $this = $(this), $next = $this.next();
            $next.slideToggle();
            $this.parent().toggleClass('open');
            if (!e.data.multiple) {
                $el.find('.submenu').not($next).slideUp("20").parent().removeClass('open');
            }
        };
        new Accordion($('#accordion'), false);
    }
}

function buildAccordion(apiData, liClass, display) {
    let html = "";
    let doc;
    if (apiData.length > 0) {
        for (let j = 0; j < apiData.length; j++) {
            html += '<li class="'+liClass+'">';
            html += '<a class="dd" href="#_' + apiData[j].link + '">' + apiData[j].order + '.&nbsp;' + apiData[j].desc + '</a>';
            html += '<ul class="sectlevel2" style="'+display+'">';
            doc = apiData[j].list;
            for (let m = 0; m < doc.length; m++) {
                html += '<li><a href="#_' + apiData[j].order + '_' + doc[m].order + '_' + doc[m].desc + '">' + apiData[j].order + '.' + doc[m].order + '.&nbsp;' + doc[m].desc + '</a> </li>';
            }
            html += '</ul>';
            html += '</li>';
        }
    }
    return html;
}